package io.reader;

import framework.AbstractTest;
import utils.Log;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Iterator;
import java.util.LinkedList;

/**
 * Created by shane on 2018/5/20.
 */
public class BufferedReaderDemo2 extends AbstractTest {
    protected static final String TAG = BufferedReaderDemo2.class.getName();

    @Override
    public void test(String[] args) {
        super.test(args);

        String testFilePath = getDefInputFile(args);

        try {
            BufferedReader bis = new BufferedReader(new FileReader(testFilePath));
            LinkedList<String> linkedList = new LinkedList<>();
            String s;
            while ((s = bis.readLine()) != null) {
                linkedList.add(s);
            }
            bis.close();

            Log.v("==========BufferedReaderDemo2==========");
            Iterator<String> iterable = linkedList.descendingIterator();
            while (iterable.hasNext()) {
                Log.v(iterable.next());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected String getTag() {
        return TAG;
    }
}
